<template>
<el-container class="layout-container">
  <!-- left -->
  <el-aside
  class="aside"
  :width="isCollapse?'64px':'200px'" >
  <!-- begin -->
    <h5 class="head">后   台</h5>
    <el-menu
    :router="true"
      default-active="/"
      @open="handleOpen"
      @close="handleClose"
        background-color="#002033"
      text-color="#fff"
      active-text-color="#ffd04b"
              :collapse="isCollapse"
         :collapse-transition="false">
      <el-submenu index="/before">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>文章管理</span>
        </template>
          <el-menu-item index="/list">
          <i class="el-icon-document"></i>
        <span slot="title">内容管理</span>
        </el-menu-item>
          <!-- <el-menu-item index="/fa">修改内容</el-menu-item> -->
          <el-menu-item index="/jing">
          <i class="el-icon-star-on"></i>
        <span slot="title">精选内容</span>
        </el-menu-item>
          <el-menu-item index="/userlist">
          <i class="el-icon-news"></i>
        <span slot="title">用户管理</span>
        </el-menu-item>
      </el-submenu>
      <el-menu-item index="/fabu">
        <i class="el-icon-s-promotion"></i>
        <span slot="title">发布讨论</span>
      </el-menu-item>
      <el-menu-item index="/user">
        <i class="el-icon-user"></i>
        <span slot="title">个人中心</span>
      </el-menu-item>
    </el-menu>
  </el-aside>
  <!-- left-end -->
  <el-container>
    <!-- mid -->
    <el-header class="header">
      <div @click="isCollapse=!isCollapse">
          <i
          :class="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold' "></i>
          <span>后台管理系统</span>
        </div>
        <el-dropdown>
        </el-dropdown>
      <!-- <el-breadcrumb separator-class="el-icon-arrow-right">
  <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  <el-breadcrumb-item>活动管理</el-breadcrumb-item>
  <el-breadcrumb-item>活动列表</el-breadcrumb-item>
  <el-breadcrumb-item>活动详情</el-breadcrumb-item>
</el-breadcrumb> -->
    </el-header>
    <!-- mid -->
    <!-- last -->
    <el-main class="main">
  <router-view></router-view>
  </el-main>
  </el-container>
</el-container>
</template>

<script>
export default {
  name: 'Layout',
  data () {
    return {
      isCollapse: false, // 是否侧边栏是收起状态
      form: {
        title: '随心而动随刃而行',
        content: '嚣张6666666666666666'
      }
      // isCollapse: false // 是否侧边栏是收起状态
    }
  },
  methods: {
    handleOpen (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath)
    },
    Ydian () {
      console.log(666)
      const data = new Date(1608047410)
      console.log(data)
      const y = data.getFullYear()
      console.log(y)
      console.log(777)
      this.$http.get('http://localhost:8080/user.json').then((response) => {
        console.log(response.data.wen)
        // console.log(response.data.assets[0].username)
        // console.log(JSON.stringify(response.data))
      })
    },
    xiugai () {
      const id = 1
      this.$http.patch('http://localhost:3000/wen/' + id, this.form).then((res) => {
        console.log(res)
        // console.log(response.data.assets[0].username)
        // console.log(JSON.stringify(response.data))
      })
    },
    Yquit () {
      // 问一下：是否要退出
      this.$confirm('你真的要走吗?').then(() => {
        // 确定退出
        // 删除token
        // localStorage.removeItem('tokenStr')
        //  回去登陆页
        this.$router.push('/login')
      }).catch(() => {
      })
    }
  },
  mounted () {
    this.Ydian()
    this.$router.push('/list')
  }
}
</script>
<style scoped lang="less">
.layout-container {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.aside {
  background-color: rgb(0,34,68);
  color: white;
  .el-menu {
    border-right: none;
  }
}
.nav-menu {
  .iconfont {
    margin-right: 10px;
    padding-left: 5px;
  }
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ccc;
  .avatar-wrap {
    display: flex;
    align-items: center;
    .avatar {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      margin-right: 10px;
    }
  }
}
.main {
  background-color: #e9eef3;
}
  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }
  .head{
          width: 100%;
      height: 30px;
            line-height: 30px;
  }
</style>
